﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 设计模式之禅.策略模式
{
    /// <summary>
    /// 抽象策略角色类
    /// </summary>
    public abstract class abstractStrategy
    {
        public abstract string Say();
    }

    /// <summary>
    /// 具体策略实现类A
    /// </summary>
    public class ConcreteStrategyA : abstractStrategy
    {
        public override string Say()
        {
            return " AAA ";
        }
    }
    /// <summary>
    /// 具体策略实现类B
    /// </summary>
    public class ConcreteStrategyB : abstractStrategy
    {
        public override string Say()
        {
            return " BBB ";
        }
    }


    /// <summary>
    /// 环境类
    /// </summary>
    public class Context
    {
        private abstractStrategy strategy;
        public Context(abstractStrategy strategy)
        {
            this.strategy = strategy;
        }

        public string DoSomething()
        {
            return this.strategy.Say();
        }
    }
}
